package server.model.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 创建人:    xvzhe
 * 创建时间:
 * 修改时间:
 * 版本:      v1.0
 */
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@DynamicInsert
@DynamicUpdate
@ApiModel("钱包记录")
public class BlanceRecord {
    @Id
    @GeneratedValue(generator = "NumberIdProduce")
    @GenericGenerator(name = "NumberIdProduce", strategy = "server.tool.idProduce.NumberIdProduce")
    private String id;

    private String userId;

    private String blanceId;

    @Column(columnDefinition = "tinyint default 1")
    private boolean status;

    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum Type {
        TOTAL_INS("签到积分"),
        TOTAL_EEL("抽奖扣除"),
        TOTAL_III("抽奖奖励"),
        ONE("直推奖励"),
        TWO("间接奖励"),
        THREE("辅导奖励"),
        TRANS_INS("转入"),
        TRANS_DEL("转出"),
        DEPOSIT("提现"),
        DK("抵扣"),
        AD_INS("管理员充值"),
        AD_DEL("管理员扣减");

        Type(String display) {
            this.display = display;
        }

        private String display;

        public String getDisplay() {
            return display;
        }

        public void setDisplay(String display) {
            this.display = display;
        }
    }

    @Enumerated(EnumType.STRING)
    @Column
    private Type type;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @LastModifiedDate
    @Column
    private Date modifiedTime;

    @Column
    private BigDecimal befor;

    @Column
    private BigDecimal after;

    @Column
    private String log;

    @Column
    private UserBlance.Type uType;
}
